#include "pthread_mqueue.h"
#include <stdio.h>
#include <unistd.h>
#define MQUEUE_NAME "/test"
int main(void)
{
    struct mq_attr attr;
    attr.mq_maxmsg = 10;
    attr.mq_msgsize = 128;
    char recv_buf[128] = {0};
    mqd_t mqd = mq_open(MQUEUE_NAME,O_RDWR|O_CREAT,0666,&attr);
    if (mqd == (mqd_t)-1)
    {
      perror("mqueue creat fail...\n");  
      return -1;
    }
    int res = mq_send(mqd,"helloword",9,0);
    if (res == -1)
    {
        perror("mqueue send fail...\n");
    }
    res = mq_receive(mqd,recv_buf,128,0);
    if (res == -1)
    {
        perror("mqueue receive fail...\n");
    }
    else
    {
        printf("msg=%.*s\n",res,recv_buf);
    }
    mq_close(mqd);
    mq_unlink(MQUEUE_NAME);
    return 0;
}